'''
Created on 2010-6-26

@author: Zizon
'''
from HTMLParser import HTMLParser

class PinPageProcessor(HTMLParser):
    pin_code = ""
    match = False
    
    def handle_starttag(self, tag, attrs):
        if tag == "div":
            attributes = dict(attrs)
            if attributes is not None and "id" in attributes.keys() and attributes["id"] == "oauth_pin":
                self.match = True

    def handle_data(self, data):
        if self.match is True:
            self.pin_code = data.replace("\r" , "").replace("\n","").replace(" " , "")
            self.match = False
